package srjava.server;

import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.XmlRpcRequest;
import org.apache.xmlrpc.server.RequestProcessorFactoryFactory;

public class CoordinatorRequestProcessorFactoryFactory implements
		RequestProcessorFactoryFactory {

	private final RequestProcessorFactory factory = new CoordinatorRequestProcessorFactory();
	private final Coordinator coordinator;

	public CoordinatorRequestProcessorFactoryFactory(Coordinator coordinator) {
		this.coordinator = coordinator;
	}

	public RequestProcessorFactory getRequestProcessorFactory(Class aClass)
	         throws XmlRpcException {
		return factory;
	}

	private class CoordinatorRequestProcessorFactory implements RequestProcessorFactory {
		public Object getRequestProcessor(XmlRpcRequest arg0)
				throws XmlRpcException {
			return coordinator;
		}
	}

}
